package cn.wolfcode.wolf2w.web.controller;

import cn.wolfcode.wolf2w.service.IDestinationService;
import cn.wolfcode.wolf2w.service.IRegionService;
import cn.wolfcode.wolf2w.service.IStrategyCatalogService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.uitl.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//给前端数据
@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IStrategyService strategyService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @GetMapping("/getHot")
    public Object getHot(){
        return JsonResult.success(regionService.queryHor());
    }

    @GetMapping("/search")
    public Object search(String regionId){//目的地id
        return JsonResult.success(destinationService.queryDestByRegionId(regionId));
    }

    /**
     * 通过目的地id查询攻略分类和明细
     * @param regionId
     * @return
     */
    @GetMapping("/catalogs")
    public Object catalogs(String destId){//目的地id
        return JsonResult.success(strategyCatalogService.queryDestByRegionId(destId));
    }
    /**
     *   吐司操作
     *   通过传过来的选中的目的地id
     */
    @GetMapping("/toasts")
    public Object toasts(String destId){//目的地id
        return JsonResult.success(destinationService.createTost(destId));
    }
    /**
     *   吐司操作
     *   通过传过来的选中的目的地id
     */
    @GetMapping("/strategies/viewnumTop3")
    public Object viewnumTop3(String destId){//目的地id
        return JsonResult.success(strategyService. viewnumTop3(destId));
    }


}
